import {exec,spawn} from 'child_process';
const os=require("os");

function openKeyBoard(cb){
  if (os.platform() === 'win32') {
    //window._PKeyboard=exec('osk.exe',{},cb);
    window._PKeyboard=spawn('osk.exe',[],{shell:true});
  } else {
    //window._PKeyboard=exec('onboard',{},cb);
    window._PKeyboard=spawn('onboard',[],{shell:true});
  }
  window._PKeyboard.on('close', cb);
  window._PKeyboard.on('error', (err) => {
    console.error(err);
  });
}

function killKeyBoard() {
  exec('taskkill /im osk.exe /f', {}, (error, stdout, stderr) => {
    if (error) {
      console.error(`执行的错误: ${error}`);
      return;
    }
    console.log(`stdout: ${stdout}`);
    console.error(`stderr: ${stderr}`);
  });
}

export {
  openKeyBoard,killKeyBoard
}